<?php
class At_User extends Zend_Auth{

    public static function getInstance()
    {
        if (null === self::$_instance) {
            self::$_instance = new self();
        }

        return self::$_instance;
    }

    public function getStorage()
    {
        if (null === $this->_storage) {
            $this->setStorage(new At_User_Storage());
        }

        return $this->_storage;
    }

    /**
     * Authenticates against the supplied adapter
     *
     * @param  Zend_Auth_Adapter_Interface $adapter
     * @return Zend_Auth_Result
     */
    public function authenticate(Zend_Auth_Adapter_Interface $adapter)
    {
        $result = $adapter->authenticate();

        if ($result->isValid()) {
			$row = $adapter->getResultRowObject( null, 'password' );
            $this->getStorage()->write($row);
        }

        return $result;
    }
}
?>
